<html>
<head><meta charset="utf-8"><title>test functions naming convention · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/test.20functions.20naming.20convention.html">test functions naming convention</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="216125784"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/test%20functions%20naming%20convention/near/216125784" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/test.20functions.20naming.20convention.html#216125784">(Nov 09 2020 at 18:34)</a>:</h4>
<p>This might be a good addition to the style guide, assuming it matters, but should unit #[test] functions be prefixed with <code>test_</code>? Just realized that sometimes they are prefixed and sometimes they aren't</p>



<a name="216144269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/test%20functions%20naming%20convention/near/216144269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/test.20functions.20naming.20convention.html#216144269">(Nov 09 2020 at 21:20)</a>:</h4>
<p>I am undecided on this one</p>



<a name="216144357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/test%20functions%20naming%20convention/near/216144357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/test.20functions.20naming.20convention.html#216144357">(Nov 09 2020 at 21:21)</a>:</h4>
<p>One one hand, <code>test_</code> is unneeded,  because it duplicates <code>#[test]</code>. On the other hand, looking for workspace symbols with  <code>test_</code> is convenient. On the third hand, there really should be a "look only in tests/only not in tests" checkbox for worksacpace search</p>



<a name="216144431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/test%20functions%20naming%20convention/near/216144431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/test.20functions.20naming.20convention.html#216144431">(Nov 09 2020 at 21:22)</a>:</h4>
<p>Is there some ecosystem-wide convention for this?</p>



<a name="216144947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/test%20functions%20naming%20convention/near/216144947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/test.20functions.20naming.20convention.html#216144947">(Nov 09 2020 at 21:27)</a>:</h4>
<p>I don't think there is a convention for this. The <a href="https://doc.rust-lang.org/book/ch11-01-writing-tests.html">book chapter</a> regarding testing doesn't prefix with <code>test_</code> which is the only place that comes to mind as some kind of reference point.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>